package com.hl.sfzy.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 课程购买记录表
 * @TableName course_buy
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CourseBuy {
    /**
     * 编号
     */
    private Integer courseBuyId;

    /**
     * 课程编号
     */
    private Integer courseId;

    /**
     * 用户编号
     */
    private Integer userId;

    /**
     * 购买价格
     */
    private BigDecimal courseBuyPrice;

    /**
     * 购买时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date courseBuyTime;

    private Course course; //课程

    /**
     * 购买状态
     */
    private Integer courseBuyState;

    /**
     * 编号
     */
    public Integer getCourseBuyId() {
        return courseBuyId;
    }

    /**
     * 编号
     */
    public void setCourseBuyId(Integer courseBuyId) {
        this.courseBuyId = courseBuyId;
    }

    /**
     * 课程编号
     */
    public Integer getCourseId() {
        return courseId;
    }

    /**
     * 课程编号
     */
    public void setCourseId(Integer courseId) {
        this.courseId = courseId;
    }

    /**
     * 用户编号
     */
    public Integer getUserId() {
        return userId;
    }

    /**
     * 用户编号
     */
    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    /**
     * 购买价格
     */
    public BigDecimal getCourseBuyPrice() {
        return courseBuyPrice;
    }

    /**
     * 购买价格
     */
    public void setCourseBuyPrice(BigDecimal courseBuyPrice) {
        this.courseBuyPrice = courseBuyPrice;
    }

    /**
     * 购买时间
     */
    public Date getCourseBuyTime() {
        return courseBuyTime;
    }

    /**
     * 购买时间
     */
    public void setCourseBuyTime(Date courseBuyTime) {
        this.courseBuyTime = courseBuyTime;
    }

    /**
     * 购买状态
     */
    public Integer getCourseBuyState() {
        return courseBuyState;
    }

    /**
     * 购买状态
     */
    public void setCourseBuyState(Integer courseBuyState) {
        this.courseBuyState = courseBuyState;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CourseBuy other = (CourseBuy) that;
        return (this.getCourseBuyId() == null ? other.getCourseBuyId() == null : this.getCourseBuyId().equals(other.getCourseBuyId()))
            && (this.getCourseId() == null ? other.getCourseId() == null : this.getCourseId().equals(other.getCourseId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getCourseBuyPrice() == null ? other.getCourseBuyPrice() == null : this.getCourseBuyPrice().equals(other.getCourseBuyPrice()))
            && (this.getCourseBuyTime() == null ? other.getCourseBuyTime() == null : this.getCourseBuyTime().equals(other.getCourseBuyTime()))
            && (this.getCourseBuyState() == null ? other.getCourseBuyState() == null : this.getCourseBuyState().equals(other.getCourseBuyState()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getCourseBuyId() == null) ? 0 : getCourseBuyId().hashCode());
        result = prime * result + ((getCourseId() == null) ? 0 : getCourseId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getCourseBuyPrice() == null) ? 0 : getCourseBuyPrice().hashCode());
        result = prime * result + ((getCourseBuyTime() == null) ? 0 : getCourseBuyTime().hashCode());
        result = prime * result + ((getCourseBuyState() == null) ? 0 : getCourseBuyState().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", courseBuyId=").append(courseBuyId);
        sb.append(", courseId=").append(courseId);
        sb.append(", userId=").append(userId);
        sb.append(", courseBuyPrice=").append(courseBuyPrice);
        sb.append(", courseBuyTime=").append(courseBuyTime);
        sb.append(", courseBuyState=").append(courseBuyState);
        sb.append("]");
        return sb.toString();
    }
}